﻿using UML_Creator.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UML_Creator.Command
{
    // Bruges til at tilføje en kant til kant samlingen.
  
    public class AddEdgeCommand : IUndoRedoCommand
    {
        private ObservableCollection<Edge> edges;
        private Edge edge;
        private Diagram endA;
        private Diagram endB;
        private int edgeType;

        public AddEdgeCommand(ObservableCollection<Edge> _edges, Diagram _endA, Diagram _endB, int _edgeType) { 
            edges = _edges; 
            endA = _endA; 
            endB = _endB;
            edgeType = _edgeType;
        }

        public void Execute()
        {
            if(edgeType == (int) UML_Creator.ViewModel.EnumEdgeType.FullLineEdge) edge = new FullLineEdge() { };
            else if (edgeType == (int)UML_Creator.ViewModel.EnumEdgeType.DiamondEdge) edge = new DiamondEdge() { };
            else if (edgeType == (int)UML_Creator.ViewModel.EnumEdgeType.FilledDiamondEdge) edge = new FilledDiamondEdge() { };
            else if (edgeType == (int)UML_Creator.ViewModel.EnumEdgeType.ArrowEdge) edge = new ArrowEdge() { };
            else if (edgeType == (int)UML_Creator.ViewModel.EnumEdgeType.DashedArrowEdge) edge = new DashedArrowEdge() { };

            edge.EndA = endA;
            edge.EndB = endB;
            edges.Add(edge);
        }

        public void UnExecute()
        {
            edges.Remove(edge);
        }

        public void ReExecute()
        {
            edges.Add(edge);
        }
    }
}
